$(function () {
    $("#jqGrids").Grid({
        url: '../user/list?userLevelId=0',
        colModel: [
            {
                label: 'id', name: 'id', index: 'id', key: true, hidden: true
            }, {
                label: '会员名称', name: 'username', index: 'username',align:'center',width: 80
            }, {
                label: '会员密码', name: 'password', index: 'password', hidden: true
            }, {
                label: '性别', name: 'gender', index: 'gender',align:'center',width: 30, formatter: function (value) {
                    return transGender(value);
                }
            }, {
                label: '出生日期', name: 'birthday', index: 'birthday',align:'center', width: 70, formatter: function (value) {
                    return transDate(value);
                }
            }, {
                label: '注册时间', name: 'registerTime', index: 'register_time',align:'center', width: 70, formatter: function (value) {
                    return transDate(value);
                }
            }, {
                label: '最后登录时间', name: 'lastLoginTime', index: 'last_login_time',align:'center', width: 70, formatter: function (value) {
                    return transDate(value);
                }
            }, {
                label: '最后登录Ip', name: 'lastLoginIp', index: 'last_login_ip', hidden: true
            }, {
                label: '会员等级', name: 'levelName',align:'center', width: 40
            }, {
                label: '微信名', name: 'nickname', index: 'nickname',align:'center', width: 80
            }, {
                label: '手机号码', name: 'mobile', index: 'mobile', align:'center',width: 120
            }, {
                label: '注册Ip', name: 'registerIp', index: 'register_ip', hidden: true
            }, {
                label: '头像', name: 'avatar', index: 'avatar',align:'center', width: 40, formatter: function (value) {
                    return transImg(value);
                }
            }, {
                label: '微信Id', name: 'weixinOpenid', index: 'weixin_openid', width: 80, hidden: true
            },{
                label: '账户余额', name: 'balanceFee', index: 'balance_fee', align:'center',width: 80
            }
        ]
    });
    var newHeight = $(window).height()-130;
    $(".ui-jqgrid .ui-jqgrid-bdiv").css("cssText","height: "+newHeight+"px!important;");
});

var vm = new Vue({
    el: '#rrappp',
    data: {
        showList: true,
        title: null,
        user: {
            gender: 1
        },
        ruleValidate: {
            username: [
                {required: true, message: '会员名称不能为空', trigger: 'blur'}
            ]
        },
        q: {
            username: ''
        },
        userLevels: []
    },
    methods: {
        query: function () {
            vm.reload();
        },
        reload: function (event) {
            vm.showList = true;
            var page = $("#jqGrids").jqGrid('getGridParam', 'page');
            $("#jqGrids").jqGrid('setGridParam', {
                postData: {'username': vm.q.username},
                page: page,
            }).trigger("reloadGrid");
            vm.handleReset('formValidate');
        },
        toRemit:function () {
            Ajax.request({
                type: "POST",
                url: "../user/remit",
                contentType: "application/json",
                successCallback: function (r) {
                    alert('操作成功', function (index) {
                        console.log("请求成功")
                    });
                }
            });
        },
        remitList:function(remitType){
            console.log("转账记录" + remitType);
        },
        handleReset: function (name) {
            handleResetForm(this, name);
        }
    }
});
